import {debounce} from "@/common/utils";
import backTop from "@/components/content/backTop/BackTop";

export const itemListenerMixin = {
  data() {
    return {
      itemImgListener: null
    }
  },
  mounted() {
    // 监听图片加载完成
    // this.$refs.scroll.refresh 进行防抖操作
    let newRefresh = debounce(this.$refs.scroll.refresh, 100)
    // 对监听事件进行保存
    this.itemImgListener = () => {
      newRefresh()
    }
    this.$bus.$on('itemImageLoad', this.itemImgListener)
  }
}

export const backTopMixin = {
  components: {
    backTop
  },
  data() {
    return {
      isShowBackTop: false
    }
  },
  methods: {
    backClick() {
      this.$refs.scroll.scrollTo(0,0)
    },
  }
}
